<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
      .box{
        width: 100px;
        height: 100px;
        background-color: bisque;
      }
      @keyframes shake-from {
        0%{
          opacity: 0;
          transform: translateX(0);
        }
        50%{
          opacity:.5;
          transform:translateX(50px);
        }
        100%{
          opacity: 1;
          transform: translateX(0);
        }
        
      }
      @keyframes shake-to {
        0%{
          opacity:1;
          transform: translateX(0);
        }
        50%{
          opacity: .5;
          transform: translateX(50px);
        }

        100%{
          opacity: 0;
          transform: translateX(0);
        }
        
        
      }

      .lk-enter-active{
        animation:2s shake-from;
      }
      .lk-leave-active{
        animation: shake-to 2s;

      }
    </style>
  </head>
  <body>
    <div id="app">
      
    </div>
    
    <script src="../js/vue.js"></script>

    <script>
      const app = Vue.createApp({
        data() {
          return {
            msg: "2021年8月20日17:41:45",
            flag:false

          }
        },
        template:`
          <transition>
            <div class="box" v-show="flag">{{msg}}</div>
          </transition>
          <transition name='lk'>
            <div class="box" v-show="flag">{{msg}}</div>
          </transition>
          <button @click="flag = !flag">显示/隐藏</button>
        `
      }).mount("#app");
    </script>
  </body>
</html>